package cn.iocoder.yudao.module.handguard.controller.admin.hometwo;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.handguard.controller.admin.hometwo.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.hometwo.HomeTwoDO;
import cn.iocoder.yudao.module.handguard.convert.hometwo.HomeTwoConvert;
import cn.iocoder.yudao.module.handguard.service.hometwo.HomeTwoService;

@Tag(name = "管理后台 - 首页成交榜-列")
@RestController
@RequestMapping("/hutai/home-two")
@Validated
public class HomeTwoController {

    @Resource
    private HomeTwoService homeTwoService;

//    @PostMapping("/create")
//    @Operation(summary = "创建首页成交榜-列")
//    @PreAuthorize("@ss.hasPermission('hutai:home-two:create')")
//    public CommonResult<Long> createHomeTwo(@Valid @RequestBody HomeTwoCreateReqVO createReqVO) {
//        return success(homeTwoService.createHomeTwo(createReqVO));
//    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新首页成交榜-列")
//    @PreAuthorize("@ss.hasPermission('hutai:home-two:update')")
//    public CommonResult<Boolean> updateHomeTwo(@Valid @RequestBody HomeTwoUpdateReqVO updateReqVO) {
//        homeTwoService.updateHomeTwo(updateReqVO);
//        return success(true);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除首页成交榜-列")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('hutai:home-two:delete')")
//    public CommonResult<Boolean> deleteHomeTwo(@RequestParam("id") Long id) {
//        homeTwoService.deleteHomeTwo(id);
//        return success(true);
//    }

    @GetMapping("/get")
    @Operation(summary = "获得首页成交榜-列")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('hutai:home-one:query')")
    public CommonResult<HomeTwoRespVO> getHomeTwo(@RequestParam("id") Long id) {
        HomeTwoDO homeTwo = homeTwoService.getHomeTwo(id);
        return success(HomeTwoConvert.INSTANCE.convert(homeTwo));
    }

    @GetMapping("/list")
    @Operation(summary = "获得首页成交榜-列列表")
    @PreAuthorize("@ss.hasPermission('hutai:home-one:query')")
    public CommonResult<List<HomeTwoRespVO>> getHomeTwoList() {
        List<HomeTwoDO> list = homeTwoService.getHomeTwoList();
        return success(HomeTwoConvert.INSTANCE.convertList(list));
    }

//    @GetMapping("/page")
//    @Operation(summary = "获得首页成交榜-列分页")
//    @PreAuthorize("@ss.hasPermission('hutai:home-two:query')")
//    public CommonResult<PageResult<HomeTwoRespVO>> getHomeTwoPage(@Valid HomeTwoPageReqVO pageVO) {
//        PageResult<HomeTwoDO> pageResult = homeTwoService.getHomeTwoPage(pageVO);
//        return success(HomeTwoConvert.INSTANCE.convertPage(pageResult));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出首页成交榜-列 Excel")
//    @PreAuthorize("@ss.hasPermission('hutai:home-two:export')")
//    @OperateLog(type = EXPORT)
//    public void exportHomeTwoExcel(@Valid HomeTwoExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<HomeTwoDO> list = homeTwoService.getHomeTwoList(exportReqVO);
//        // 导出 Excel
//        List<HomeTwoExcelVO> datas = HomeTwoConvert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "首页成交榜-列.xls", "数据", HomeTwoExcelVO.class, datas);
//    }

}
